- drawing of three dimensional curves in Xi -
The drawing of curves in a three dimensional space is similar to the drawing of in the plane (see Function Plots). You simply define a set of points in space and connect them with lines (in future versions of Xi they optionally may be connected by a spline).
In detail: say you want to plot a spiral line (or a helix) given by the following formular.
x(t) = cos(t) y(t) = sin(t) z(t) = tFirst open a graphic device with the /t3d option so that the 3d graphic commands can be utilized. Since we also want to use some colors, open the graphic device with enough bits per pixels, defined by the /bpp argument.
( 1)>window(0,\bpp=3,\t3d);Next define the 't' interval. Say you want to draw the spiral line from 0 to 2*pi and want to subdive this interval into 200 tiles. For this purpose again use the interval function:
( 2)>t=interval(0,2*~pi,200); Function interval definedNow we a ready to plot the spiral line in red:
( 3)>plot3d(cos(t),sin(t),t,\color=2,\line);To make the picture a little more interesting we draw the same curve in green with x,y exchanged:
( 4)>plot3d(sin(t),cos(t),t,\color=3,\line);In the projection the two curves look a little strange they actually look like plots of the sinus and cosinus functions not like real spirals. Before we change this some words on the 3d graphic device of Xi:
Internally the 3d graphic device is the unit cube with corners (0,0,0) and (1,1,1). By default you look at this cube in y direction with z up and x right. The following picture might illustrate this:
At first sight this may look unnecessary complicated, but in the authors opinion it is the only way if you want to place more than one plot in a graphic device and want to be compatible with real 3d devices like povray (explained below). If you have a better idea, tell Bodo and he'll see, what he can do.
Now, return to our example. Let's turn the plot so one could better recognize the spirals. In Xi the orientation of a plot is defined by three Euler-angles (in physics these are normally defined, if one is interested in the dynamics of a spinning top). The first angle defines a rotation around the z axis, the next angle defines a rotation around the y axis and the last angle again is a rotation around the z axis. If one does these rotations in the presented order, the orientation of the plot is one-to-one defined by these three angles. In this case a good choice for these angles would be 60,30,-90. Let's turn the plot:
( 5)>plot3d(\angle={60,30,-90});Now it is clear how the spirals lie in space. The x and y axis are not stated yet. To entitle them type:
( 6)>plot3d(\xtitle="x",\ytitle="y");Of course you can also put a title to the z axis with the \ztitle argument but in this case this isn't necessary.
Finally we want to make a nice povray picture of this situation. First open a poyray device in a similar way you have opened the X device:
( 7)>window(1,\bpp=3,\t3d,\pov);Next repeat the commands from above in short notation:
( 8)>plot3d(cos(t),sin(t),t,\color=2,\line); ( 9)>plot3d(sin(t),cos(t),t,\color=3,\line); ( 10)>plot3d(\angle={60,30,-90},\xtitle="x",\ytitle="y");Press the left or right mouse buttom in the X11-window to rotate the plot. Finaly close the device:
( 11)>window(1,\close);Xi now has generated the file xigraph.pov in the actual working directory. This file can be use as input for povray. If povray is found in your standard search path, you may type:
( 12)>$ povray +ixigraph.pov -oxigraph.tga +w700 +h700 -d +ft Persistence of Vision Raytracer Ver 2.2linux386 This is an unofficial version compiled by: Jeff Epler (jepler@herbie.unl.edu) The POV-Ray Team is not responsible for supporting this version. Copyright 1993 POV-Team ---------------------------------------------------------------------- POV-Ray is based on DKBTrace 2.12 by David K. Buck & Aaron A. Collins. Contributing Authors: (Alphabetically) Steve Anger Steve A. Bennett David K. Buck Aaron A. Collins Alexander Enzmann Dan Farmer Douglas Muir Bill Pulver Robert Skinner Scott Taylor Drew Wells Chris Young Other contributors listed in the documentation. ---------------------------------------------------------------------- POV-Ray Options in effect: +v1 +ft +mb25 -q9 -w700 -h700 -s1 -e700 -k0.000 -mv2.0 -ixigraph.pov -oxigraph.tga -l/home/junglas/pov/include Parsing.............................................. Preprocessing... POV-Ray rendering xigraph.pov to xigraph.tga : Res 700 X 700. Calc line 700 of 700. xigraph.pov statistics -------------------------------------- Resolution 700 x 700 # Rays: 490000 # Pixels: 490000 # Pixels supersampled: 0 Ray->Shape Intersection Tests: Type Tests Succeeded Percentage ----------------------------------------------------------- Sphere 120410 3925 3.26 Box 508769 35021 6.88 Cone 60205 51070 84.83 Bounds 508769 60205 11.83 Calls to DNoise: 10 Shadow Ray Tests: 40551 Blocking Objects Found: 1372 Time For Trace: 0 hours 1 minutes 0.00 secondspovray has now generated a 700x700 Targa-file named xigraph.tga.
The result (after crob) looks like this: